import Mock from 'mockjs'

// 登录
Mock.mock(`${window.$mockApi}/login`, "post", (data) => {
    let mockData = JSON.parse(data.body)
    let back = {}
    if (mockData.username === "admin" && mockData.password === "123qwe") {
        back = {
            result: {
                token: "admin",
            },
            success: true,
            status: 200
        }
    } else {
        back = {
            result: null,
            success: false,
            error: {
                message: "登录错误"
            },
            status: 500
        }
    }
    return back
})

// 获取权限信息
Mock.mock(`${window.$mockApi}/getInfo`, "post", (data) => {
    let mockData = data.body
    let back = {}
    if (mockData === "admin") {
        back = {
            "result": {
                "user": {
                    "name": "admin",
                    "userName": "admin",
                    "emailAddress": "admin@qq.com",
                    "id": 1
                },
                "permissions": [
                    "System",
                    "Game",
                    "Report",
                    "System.Config",
                    "System.Role",
                    "System.Manager",
                    "System.LoginLog",
                    "System.OperationLog"
                ]
            },
            "success": true,
            "status": 200
        }
    }
    return back
})

export default Mock
